<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.6"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>ADXL362DMA: ADXL362DMA</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr id="projectrow">
  <td id="projectalign">
   <div id="projectname">ADXL362DMA
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.6 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search/",'.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
</div><!-- top -->
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">Loading...</div>
<div class="SRStatus" id="Searching">Searching...</div>
<div class="SRStatus" id="NoMatches">No Matches</div>
</div>
</div>
</div>
</div>

<div><div class="header">
  <div class="headertitle"><div class="title"><a class="el" href="class_a_d_x_l362_d_m_a.html" title="Class for ADXL362 accelerometer, connected by SPI.">ADXL362DMA</a> </div></div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p><a class="anchor" id="md_README"></a><em>Library for ADXL362 accelerometer that uses SPI DMA for efficient transfers</em></p>
<p>The ADXL362 is an inexpensive 3-DOF ultra-low power accelerometer. It can do movement detection from rest continuously at 270 nA (yes, nano-amps!) and also has a large FIFO that makes it possible to buffer samples while the processor is busy or even sleeping.</p>
<p>The GY362 is a compatible version of the ADXL362 and also works with this library.</p>
<ul>
<li><a href="https://github.com/rickkas7/ADXL362DMA">Github repository</a></li>
<li>License: MIT (free for use in open or closed source projects, including commercial products)</li>
<li><a href="http://www.analog.com/media/en/technical-documentation/data-sheets/ADXL362.pdf">Datasheet</a></li>
<li><a href="https://rickkas7.github.io/ADXL362DMA/index.html">Full browsable API documentation</a></li>
</ul>
<h1>Usage</h1>
<h2>Hardware connections</h2>
<p>This library uses the ADXL362 in SPI mode.</p>
<div class="image">
<img src="accel.png" alt=""/>
<div class="caption">
Breadboard</div></div>
    <table class="markdownTable">
<tr class="markdownTableHead">
<th class="markdownTableHeadCenter">Breakout   </th><th class="markdownTableHeadCenter">Particle Device   </th><th class="markdownTableHeadCenter">Color   </th><th class="markdownTableHeadCenter">Description    </th></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyCenter">VIN   </td><td class="markdownTableBodyCenter">3V3   </td><td class="markdownTableBodyCenter">Red   </td><td class="markdownTableBodyCenter">3.3V DC Power    </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyCenter">GND   </td><td class="markdownTableBodyCenter">GND   </td><td class="markdownTableBodyCenter">Black   </td><td class="markdownTableBodyCenter">Ground   </td></tr>
</table>
<p>| SCL / SCLK | Orange | SPI CLK | | SDA / MOSI / SDI | Blue | SPI MOSI | | SDO / MISO | Green | SPI MISO | | CS | A2 | Yellow | SPI Chip Select | | INT2 | n/c | | Interrupt 2 (not used) | | INT1 | n/c | | Interrupt 1 (not used) |</p>
<h2>Software</h2>
<p>Instantiate a global object for the accelerometer. The first parameter is the SPI bus amd the second is the CS line.</p>
<div class="fragment"><div class="line"><a class="code hl_class" href="class_a_d_x_l362_d_m_a.html">ADXL362DMA</a> accel(SPI, A2);</div>
<div class="ttc" id="aclass_a_d_x_l362_d_m_a_html"><div class="ttname"><a href="class_a_d_x_l362_d_m_a.html">ADXL362DMA</a></div><div class="ttdoc">Class for ADXL362 accelerometer, connected by SPI.</div><div class="ttdef"><b>Definition:</b> ADXL362DMA.h:23</div></div>
</div><!-- fragment --><p>Initialize the chip:</p>
<div class="fragment"><div class="line">accel.softReset();</div>
<div class="line"><span class="keywordflow">while</span>(accel.readStatus() == 0) {</div>
<div class="line">    Log.info(<span class="stringliteral">&quot;no status yet, waiting for accelerometer&quot;</span>);</div>
<div class="line">    delay(1000);</div>
<div class="line">}</div>
</div><!-- fragment --><p>Enable measuring mode (it boots into standby mode):</p>
<div class="fragment"><div class="line">accel.setMeasureMode(<span class="keyword">true</span>);</div>
</div><!-- fragment --><p> }</p>
<p>Read data. There is also a function to read roll and pitch data instead of raw data, see example 4-rollpitch.</p>
<div class="fragment"><div class="line">int16_t x, y, z;</div>
<div class="line"> </div>
<div class="line">accel.readXYZ(x, y, z);</div>
<div class="line"> </div>
<div class="line">Serial.printlnf(<span class="stringliteral">&quot;%5d %5d %5d&quot;</span>, (<span class="keywordtype">int</span>)x, (<span class="keywordtype">int</span>)y, (<span class="keywordtype">int</span>)z);</div>
</div><!-- fragment --> </div></div><!-- PageDoc -->
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.6
</small></address>
</body>
</html>
